using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MyCustomModules_MessageWidget : System.Web.UI.UserControl
{
    public string strMessageID;
    public string strCurrentUser;
    int isAdmin;


    protected void Page_Load(object sender, EventArgs e)
    {
       // if (!IsPostBack)
        {
            DataSet ds = (DataSet)Session["MessagesPosted"];
            DataRow dr = ds.Tables[0].Select("MessageID=" + strMessageID)[0];

            lblPostedBy.Text = dr["PostedByName"].ToString();
            lblTimeStamp.Text =  " [" + dr["Timestamp"].ToString() + "]";
            lblHeader.Text = dr["Message"].ToString();

            isAdmin = Convert.ToInt32(dr["IsAdmin"].ToString());

        }
    }

    protected string GetAlignment()
    {
        if (HttpContext.Current.User.IsInRole("Content Administrators") || HttpContext.Current.User.IsInRole("Admins"))
        {
            if (isAdmin==1)
                return "left";
            else
                return "right";
        }
        else
        {
            if (isAdmin == 0)
                return "left";
            else
                return "right";
        }
    }
}
